
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录</title>
    <style type="text/css">
        body, div,img,p,a,h2,table,from,input,label{
            margin : 0 ;
            padding : 0 ;
        }
    </style>
    <script type="text/javascript" src="js/jquery-3.1.1.js"></script>
</head>
<body>
<h2 style="text-align:center;letter-spacing:40px;color:pink">欢迎来到新闻注册界面</h2>
<div>
    <img src="../images/news1.png" style="width:100% ;height:150px">
</div>
<p style="text-align:center;color:red;margin-top:20px;font-size:25px;letter-spacing:20px">
    <c:if test="${not empty errorlogin }">
        ${ errorlogin }
        <c:remove var="errorlogin" scope="session"/>
    </c:if>
</p>
<div>
    <table border="0" style="margin:60px auto 0;text-align:center;font-size:30px;">
    <form  method="post" action="UserRegistServlet">
        <tr>
            <td> <label for="username">用户名:</label></td>
            <td>
                <input type="text" name="name" id="username" placeholder="请输入用户名" style="width:300px;height:30px">
                <span  id="msgspan" style="color: #ac2925"></span>
            </td>
        </tr>
        <tr>
            <td><label for="password">密  &nbsp 码:</label></td>
            <td><input type="password" name="pwd" id="password" placeholder="请输入密码" style="width:300px;height:30px"></td>
        </tr>
        <tr>
            <td><label for="userflag">用户权限:</label></td>
            <td>
                <select name="userflag" id="userflag" style="width: 300px;height: 40px;font-size: 20px" >
                    <option>
                        请选择注册用户权限
                    </option>
                    <option value="0">
                        超级管理员
                    </option>
                    <option value="1">
                        普通管理员
                    </option>
                </select>
            </td>
        </tr>
        <tr >
            <td colspan="2" align="center"><label for="submit">注册</label><input type="submit" id="submit" style="display:none" /></td>
        </tr>
    </form>

    </table>
</div>
<script type="text/javascript">
    $(function () {
        $("#username").blur(function () {
            var username = $("#username").val();
            $.ajax({
                url: "RegistUserNameServlet",
                type: "POST",
                data: {
                    'username':username
                },
                success: function (result) {
                    $("#msgspan").html(result)
                    if("此用户已经存在" ==  result){
                        $("#submit").attr('disabled',true);
                    }else{
                        $("#submit").attr('disabled',false);
                    }
                }
            });
        });
    });
</script>
</body>
</html>